<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>操作1</title>
  <link rel="stylesheet" href="./1.css">
</head>
<body>
  <form class="container" id="form">
    <div class="line form-input">
      <label class="label" for="username">用户名</label>
      <input id="username" type="text" placeholder="请输入" name="username">
    </div>
    <div class="line form-input">
      <label class="label" for="password">密码</label>
      <input id="password" type="password" placeholder="请输入" required="required" name="password">
    </div>
    <div class="line form-input">
      <label class="label">性别</label>
      <input id="man" type="radio" name="sex" value="male">
      <label for="man">男</label>
      <input id="woman" type="radio" name="sex" value="female">
      <label for="woman">女</label>
    </div>
    <div class="line form-input">
      <label class="label">学历</label>
      <input id="bk" type="radio" name="edu" value="bk">
      <label for="bk">本科</label>
      <input id="dz" type="radio" name="edu" value="dz">
      <label for="dz">大专</label>
    </div>
    <div class="line form-input">
      <label for="desc" class="label">自我介绍</label>
      <textarea name="desc" id="desc" cols="30" rows="10"></textarea>
    </div>
    <div class="line">
      <button type="submit">提交</button>
    </div>
  </form>
</body>
<script>
  var form = document.querySelector("form");
  form.addEventListener("submit", function (e) {
    var data = new FormData(form);
    var output = "";
    for (const entry of data) {
      output = entry[0] + "=" + entry[1] + "\r";
      if (entry[0] === 'desc') {
        alert("自我介绍：" + entry[1]);
      }
      console.log("formdata", output)
    }
    e.preventDefault();
  });
</script>
</html>